home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
glass
/
glass.lha
/
GLASS
/
tmc
/
calu.ht
< prev
next >
Wrap
Text File
|
1990-11-06
|
8KB
|
373 lines
/*
Copyright (C) 1990 C van Reewijk, email: dutentb.uucp!reeuwijk
This file is part of GLASS.
GLASS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
GLASS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GLASS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
.. file: calu.ht
.. Tm C support. Variant: array lists, union constructors.
/* ---- start of ${tplfilename} ---- */
/* Definition C datastructures (Version for array list).
template file: ${tplfilename}
datastructure file: ${dsfilename}
tm version: $(tmvers) ($(tmdate))
*/
.. forward reference typedefs for all types.
.. C does not like the use of undefined types, but does not
.. mind the use of pointers to (yet) undefined types.
.foreach t $(need_ds_list)
typedef struct str_$t_list *$t_list;
.endforeach
.foreach t $(need_ds)
typedef struct str_$t *$t;
.endforeach
.foreach t $(need_ds)
#define $tNIL ($t)0
.endforeach
.foreach t $(need_ds_list)
#define $t_listNIL ($t_list)0
.endforeach
.foreach t $(need_ds)
.foreach c ${conslist $t}
#define $c u.ue_$c
.endforeach
.endforeach
.foreach t $(need_ds)
.if ${len ${conslist $t}}
typedef enum en_tags_$t {
${seplist ", " ${prefix TAG ${conslist $t}}}
} tags_$t;
.endif
.endforeach
.foreach t $(need_ds)
.. Structure definitions for all the constructors of the type
.. That have elements (C does not like empty structures or unions).
.. Set 'makeunion' to true if a constructor structure has been
.. generated, because otherwise a union is not necessary.
.set makeunion 0
.if ${len ${conslist $t}}
.. Constructor type
.foreach c ${conslist $t}
.if ${len ${celmlist $t $c}}
.set makeunion 1
/* Structure for constructor $c */
typedef struct str_$c {
.foreach sname ${celmlist $t $c}
.if ${eq list ${ctypeclass $t $c $(sname)}}
${ctypename $t $c $(sname)}_list $(sname);
.else
${ctypename $t $c $(sname)} $(sname);
.endif
.endforeach
} C_$c;
.endif
.endforeach
struct str_$t {
tags_$t tag;
.if $(makeunion)
union uni_$t {
.foreach c ${conslist $t}
.if ${len ${celmlist $t $c}}
C_$c ue_$c;
.endif
.endforeach
} u;
.endif
};
.else
struct str_$t {
.foreach sname ${telmlist $t}
.if ${eq list ${ttypeclass $t $(sname)}}
${ttypename $t $(sname)}_list $(sname);
.else
${ttypename $t $(sname)} $(sname);
.endif
.endforeach
};
.endif
.endforeach
.foreach t $(need_ds_list)
struct str_$t_list {
unsigned int sz;
unsigned int room;
$t *arr;
};
.endforeach
#if defined( __STDC__ ) && __STDC__>0
/* new_<cons> and new_<type> routines */
.foreach t $(want_new)
.if ${len ${telmlist $t}}
.set tl
.foreach e ${telmlist $t}
.if ${eq single ${ttypeclass $t $e}}
.append tl ${ttypename $t $e}
.else
.append tl ${ttypename $t $e}_list
.endif
.endforeach
.if ${== ${len $(tl)} 0}
extern $t new_$t( void );
.else
extern $t new_$t( ${seplist ", " $(tl)} );
.endif
.else
.foreach c ${conslist $t}
.set tl
.foreach e ${celmlist $t $c}
.if ${eq single ${ctypeclass $t $c $e}}
.append tl ${ctypename $t $c $e}
.else
.append tl ${ctypename $t $c $e}_list
.endif
.endforeach
.if ${== ${len $(tl)} 0}
extern $t new_$c( void );
.else
extern $t new_$c( ${seplist ", " $(tl)} );
.endif
.endforeach
.endif
.endforeach
.foreach t $(want_new_list)
extern $t_list new_$t_list( void );
.endforeach
/* room_<type>_list() routines */
.foreach t $(want_room_list)
extern void room_$t_list( $t_list, unsigned int );
.endforeach
/* app_<type>_list() routines */
.foreach t $(want_app_list)
extern void app_$t_list( $t_list, $t );
.endforeach
/* append_<type>_list() routines */
.foreach t $(want_append_list)
extern $t_list append_$t_list( $t_list, $t );
.endforeach
/* ins_<type>_list() routines */
.foreach t $(want_ins_list)
extern void ins_$t_list( $t_list, unsigned int, $t );
.endforeach
/* del_<type>_list() routines */
.foreach t $(want_del_list)
extern void del_$t_list( $t_list, unsigned int );
.endforeach
/* conc_<type>_list() routines */
.foreach t $(want_conc_list)
extern void conc_$t_list( $t_list, $t_list );
.endforeach
/* concat_<type>_list() routines */
.foreach t $(want_concat_list)
extern $t_list concat_$t_list( $t_list, $t_list );
.endforeach
/* fre_<type>_list() routines */
.foreach t $(want_fre_list)
extern void fre_$t_list( $t_list );
.endforeach
.foreach t $(want_fre)
extern void fre_$t( $t );
.endforeach
/* rfre_<type>_list() routines */
.foreach t $(want_rfre_list)
extern void rfre_$t_list( $t_list );
.endforeach
.foreach t $(want_rfre)
extern void rfre_$t( $t );
.endforeach
/* print_<type>() routines */
.foreach t $(want_print)
extern void print_$t( $t );
.endforeach
.foreach t $(want_print_list)
extern void print_$t_list( $t_list );
.endforeach
/* fprint_<type>() routines */
.foreach t $(want_fprint)
extern void fprint_$t( FILE *, $t );
.endforeach
.foreach t $(want_fprint_list)
extern void fprint_$t_list( FILE *, $t_list );
.endforeach
/* rdup_<type>() routines */
.foreach t $(want_rdup)
extern $t rdup_$t( $t );
.endforeach
.foreach t $(want_rdup_list)
extern $t_list rdup_$t_list( $t_list );
.endforeach
/* fscan_<type>() routines */
.foreach t $(want_fscan)
extern int fscan_$t( FILE *, $t * );
.endforeach
.foreach t $(want_fscan_list)
extern int fscan_$t_list( FILE *, $t_list * );
.endforeach
/* cmp_<type>() routines */
.foreach t $(want_cmp)
extern int cmp_$t( $t, $t );
.endforeach
.foreach t $(want_cmp_list)
extern int cmp_$t_list( $t_list, $t_list );
.endforeach
/* misc. functions */
.if ${index flush_$(basename) $(want_misc)}
extern void flush_$(basename)( void );
.endif
.if ${index stat_$(basename) $(want_misc)}
extern void stat_$(basename)( FILE * );
.endif
#else
/* new_<cons> and new_<type> routines */
.foreach t $(want_new)
.if ${len ${telmlist $t}}
extern $t new_$t();
.else
.foreach c ${conslist $t}
extern $t new_$c();
.endforeach
.endif
.endforeach
.foreach t $(want_new_list)
extern $t_list new_$t_list();
.endforeach
/* room_<type>_list() routines */
.foreach t $(want_room_list)
extern void room_$t_list();
.endforeach
/* app_<type>_list() routines */
.foreach t $(want_app_list)
extern void app_$t_list();
.endforeach
/* append_<type>_list() routines */
.foreach t $(want_append_list)
extern $t_list append_$t_list();
.endforeach
/* ins_<type>_list() routines */
.foreach t $(want_ins_list)
extern void ins_$t_list();
.endforeach
/* del_<type>_list() routines */
.foreach t $(want_del_list)
extern void del_$t_list();
.endforeach
/* conc_<type>_list() routines */
.foreach t $(want_conc_list)
extern void conc_$t_list();
.endforeach
/* concat_<type>_list() routines */
.foreach t $(want_concat_list)
extern $t_list concat_$t_list();
.endforeach
/* fre_<type>_list() routines */
.foreach t $(want_fre_list)
extern void fre_$t_list();
.endforeach
.foreach t $(want_fre)
extern void fre_$t();
.endforeach
/* rfre_<type>_list() routines */
.foreach t $(want_rfre_list)
extern void rfre_$t_list();
.endforeach
.foreach t $(want_rfre)
extern void rfre_$t();
.endforeach
/* print_<type>() routines */
.foreach t $(want_print)
extern void print_$t();
.endforeach
.foreach t $(want_print_list)
extern void print_$t_list();
.endforeach
/* fprint_<type>() routines */
.foreach t $(want_fprint)
extern void fprint_$t();
.endforeach
.foreach t $(want_fprint_list)
extern void fprint_$t_list();
.endforeach
/* rdup_<type>() routines */
.foreach t $(want_rdup)
extern $t rdup_$t();
.endforeach
.foreach t $(want_rdup_list)
extern $t_list rdup_$t_list();
.endforeach
/* fscan_<type>() routines */
.foreach t $(want_fscan)
extern int fscan_$t();
.endforeach
.foreach t $(want_fscan_list)
extern int fscan_$t_list();
.endforeach
/* cmp_<type>() routines */
.foreach t $(want_cmp)
extern int cmp_$t();
.endforeach
.foreach t $(want_cmp_list)
extern int cmp_$t_list();
.endforeach
/* misc. functions */
.if ${index flush_$(basename) $(want_misc)}
extern void flush_$(basename)();
.endif
.if ${index stat_$(basename) $(want_misc)}
extern void stat_$(basename)();
.endif
#endif
/* ---- end of ${tplfilename} ---- */